package com.cscj.android.repository.settings

import android.graphics.Bitmap
import com.cscj.android.repository.db.entity.SearchEngineEntity
import com.cscj.android.repository.db.entity.UserAgentEntity
import com.cscj.android.repository.repo.config.WebViewConfig
import com.cscj.android.repository.settings.model.SettingConstants
import kotlinx.coroutines.flow.Flow

interface Settings {

    suspend fun init()

    //主页配置
    interface HomeSetting {

    }

    /**
     * 搜索设置
     */
    interface SearchSetting {

        suspend fun init()

        fun currentSearchEngine(): Flow<SearchEngineEntity?>

        suspend fun switchSearchEngine(engineEntity: SearchEngineEntity)

        suspend fun newEngine(
            name: String, urlPattern: String, preferred: Boolean, icon: Bitmap? = null
        )


    }

    /**
     * userAgent
     */
    interface UserAgentSetting {

        suspend fun init()

        fun currentUserAgent(): Flow<UserAgentEntity?>

        suspend fun switchUserAgent(id: Int)

        suspend fun newUserAgent(name: String, content: String, preferred: Boolean)

        fun userAgentList(): Flow<List<UserAgentEntity>>

    }

    /**
     * 收藏设置
     */
    interface FavoriteSetting {

    }

    /**
     * 设置-网页浏览设置
     * WebView需要根据此处的配置进行初始化
     */
    interface BrowserSetting {

        fun fontSizeFlow(): Flow<Int>

        suspend fun updateFontSize(fontSize: Int)

        fun readerModeFlow(): Flow<Boolean>

        suspend fun updateReaderMode(on: Boolean)

        suspend fun updateDarkMode(@SettingConstants.DarkMode darkMode: Int)

        fun darkModeFlow(): Flow<Int>

        suspend fun updateImageMode(@SettingConstants.ImageMode imageMode:Int)

        fun imageModeFlow(): Flow<Int>

        fun webViewConfigFlow(): Flow<WebViewConfig>

        fun privacyModeFlow(): Flow<Boolean>

        suspend fun updatePrivacyMode(on: Boolean)

        fun lockPortraitFlow(): Flow<Boolean>

        fun blockIntentFlow(): Flow<Boolean>

        suspend fun updateBlockIntent(block: Boolean)

        suspend fun updateLockScreen(lockPortrait: Boolean)

        suspend fun clearAll()

    }


    interface DownloadSetting {

    }

    /**
     * 广告过滤设置
     */
    interface AdBlockSetting {

    }

}